var express = require('express');
var router = express.Router();
var loginModel = require('../model/model')

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});
router.get("/login", async (req, res) => {
  const data = await loginModel.find();
  res.send({
    code: 200,
    data,
  });
});

router.post("/login", (req, res) => {
  let body = req.body;
  loginModel.create(body);
  res.send({
    code: 200,
  });
});

module.exports = router;
